from pylab import *

# x : x values
# cond_vals : the condition and the values under it
def compare_curve(ax, x, cond_vals, display_value=None):
    for label,vals in cond_vals:
        ax.plot(x, vals, '-o')
        if display_value:
            for px,py in zip(x,vals):
                ax.text(px,py, py, verticalalignment="bottom", horizontalalignment="center")
                    
    ax.set_xticks(x)
    labels = [label for label, values in cond_vals]
    ax.legend( labels, "upper right", shadow=True )
    # ax.grid(True)
    ax.yaxis.grid(True)         # only y axis
    


import pickle
x, datum = pickle.load(open("area.dat","r"))
y = []
for k,v in datum.items():
    y.append( (k, v) )

t_x, t_datum = pickle.load(open("timing.dat","r"))    
t_y = []
for k,v in t_datum.items():
    t_y.append( (k, v) )
    
# x = range(4)
# y1 = ("small", [1,2.5,3.0,4.7])
# y2 = ("medium", [2,2.7,3.1,5.8])
# y3 = ("huge", [4,3.2,4.8,5.9])

fig, ax = subplots(2, sharex=True)
# area
compare_curve(ax[0], x, y)
ax[0].set_xlim(min(x)-0.3, max(x)+1)
ax[0].set_title("Total Cell Area")


compare_curve(ax[1], t_x, t_y)
ax[1].axhline(y=0, color='k')
ax[1].set_title("Slack")

show()

